﻿<?php 

header("content-type:text/html;charset=utf-8");


date_default_timezone_set("PRC");



$pImg=$_FILES["userpic"];
$pic_name = $pImg['name'];
$pic_name = iconv('utf-8','gb2312',$pic_name);
$pic_type = $pImg['type'];
$pic_size = $pImg['size'];
$aa=explode('.',$pic_name);
$extName=strtolower(end($aa));
$str=explode('.',$pic_name);
$firstName = $str[0];

if($pic_type!="image/gif" && $pic_type!="image/bmp" && $pic_type!="image/png" && $pic_type!="image/jpeg" && $pic_type!="image/pjpeg" && $pic_type!="image/x-png"){
	$json = array('result'=> 'error_1');
	echo json_encode($json);         /////图片格式不正确
}
else if($pic_size>5240000){
	$json = array('result'=>  'error_2');
	echo json_encode($json);        /////图片过大       
}
else{
	$filename=$firstName."_".date("Ymdhis").".".$extName;
	$dest="uploadpics/".$filename;
	move_uploaded_file($pImg['tmp_name'],$dest);
	$filename = iconv('gb2312','utf-8',$filename);
	$json = array('filename'=>  $filename,'result' =>  'pass');
    echo json_encode($json);
	//echo 11;
}

?>